<template>
    <div class="content">
        <el-dialog :visible.sync="modifyAllow.dialogFormVisible" title="确定要批量审核通过吗？" size="tiny" :before-close="handleClose" > 
            <div v-loading = loading>
                <el-form :model="form" label-width="80px">
                    <el-row :gutter="20">
                        <el-col :span="7">
                            <el-form-item label=""></el-form-item>
                        </el-col>
                        <el-col :span="15">
                            <el-form-item label="总计数量:">
                            {{this.modifyAllow.length}}个
                            </el-form-item>
                        </el-col>
                        
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="7">
                            <el-form-item label=""></el-form-item>
                        </el-col>
                        <el-col :span="15">
                            <el-form-item label="总计金额:">
                            {{form.content | moneySwitch}}元
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            <footer>
              <el-button @click="handleClose">取消</el-button>
              <el-button @click="btnAdd" type="primary">确认</el-button>
            </footer>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import { settlementCount, batchCheck } from 'api/settlemain';
export default {
    name: 'unifyallow',
    props: {
        modifyAllow: {}
    },
    created() {
        this.search();
    },
    data() {
        return {
            loading: false,
            form: {
                content: ''
            }
        };
    },
    methods: {
        handleClose() {
            this.modifyAllow.dialogFormVisible = false;
        },
        search() {
            this.loading = true;
            settlementCount(this.modifyAllow.pid)
        .then(data => {
            this.loading = false;
            this.form.content = data.data.content.toFixed(2);
        })
        .catch(Error => {
            this.loading = false;
        });
        },
        btnAdd() {
            this.loading = true;
            batchCheck(this.modifyAllow.state, this.modifyAllow.pid)
        .then(data => {
            this.loading = false;
            this.modifyAllow.dialogFormVisible = false;
            this.$message({
                message: '恭喜你，通过成功！',
                type: 'success'
            });
            this.$emit('sortAllow', '成功');
            this.$store.dispatch('UpdateCache', true);
        })
        .catch(Error => {
            this.loading = false;
        });
        }
    }
};
</script>
<style lang="scss" scoped>
section,
footer {
  text-align: center;
}
.title {
  text-align: left;
  color: #999;
}
section {
  padding-bottom: 50px;
  el-button {
    margin-right: 20px;
  }
}
</style>
